import json


def enzyme_to_mrna(enzyme_name):
    filepath = "data/cleaver_fragment/cleaver_fragment_DNA.json"
    
    def load_cleaver_fragments(filepath):
        with open(filepath, 'r') as file:
            data = json.load(file)
        return {k: v for item in data["cleaver_fragment"] for k, v in item.items()}

    # Convert DNA sequence to mRNA sequence
    def dna_to_mrna(dna_seq):
        dna_to_mrna_map = {
            'A': 'U',
            'T': 'A',
            'C': 'G',
            'G': 'C'
        }
        return ''.join([dna_to_mrna_map[base] for base in dna_seq])

    cleaver_fragments = load_cleaver_fragments(filepath)
    dna_seq = cleaver_fragments.get(enzyme_name, "")

    if dna_seq:
        return dna_to_mrna(dna_seq)
    else:
        return None


if __name__ == "__main__":
    enzyme_name = "accI"
    mrna_seq = enzyme_to_mrna(enzyme_name)
    print(f"The mRNA sequence for enzyme {enzyme_name} is: {mrna_seq}")
